//
//  photoCollectionView.m
//  HuiWenMovie
//
//  Created by niceDay on 15/7/23.
//  Copyright (c) 2015年 computer. All rights reserved.
//

#import "photoCollectionView.h"

@implementation photoCollectionView

- (id)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{
    self = [super initWithFrame:frame collectionViewLayout:layout];
    if (self) {
        self.delegate = self;
        self.dataSource = self;
        [self registerClass:[photoCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
        photoCollectionViewCell *cell = [[photoCollectionViewCell alloc] initWithFrame:self.bounds];
        [self addSubview:cell];
    }
    return self;
}

- (void)setImageUrlArray:(NSMutableArray *)imageUrlArray{
    _imageUrlArray = imageUrlArray;
    [self reloadData];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return _imageUrlArray.count;
    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    photoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.imageUrl = _imageUrlArray[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
    photoCollectionViewCell *photoCell = (photoCollectionViewCell *)cell;
    
    photoScrollView *scrollView =(photoScrollView *)[photoCell.contentView viewWithTag:100];
    
    scrollView.zoomScale = 1.0;
    
    
}
@end
